from pymysql import Connection

# 构建MySQL数据库的连接
connect = Connection(
    host='172.16.100.10',
    port=3306,
    user='root',
    password='Tcdn@2007.',
    autocommit=True
)

# 执行非查询性质SQL
cursor = connect.cursor()
# 选择数据库
connect.select_db("world")
# 执行sql
cursor.execute("insert into student values (10078, '张小强', 31, '男')")
# 通过 commit 确认
# connect.commit()
# 关闭链接
connect.close()